<?php

/**
 * 餐厅标签管理
 * 
 * @author zhangchao
 * @since 2012-04-20
 */

include_once($_SERVER["DOCUMENT_ROOT"] . "/core/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/core/admin.inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/foodv2/inc.php");

$g_cgival = array();
$g_pro = array();
$g_show = array();


function check_cgi_pro()
{
	global $g_cgival, $g_pro, $g_show;
	
	cgi::both($g_cgival["rstrt_id"], "rstrt_id", 0);
	$g_cgival["rstrt_id"] = intval($g_cgival["rstrt_id"]);
	if($g_cgival["rstrt_id"] <= 0)
	{
		throw new Exception('rstrt_id不合法');
	}
}

function get_data()
{
	global $g_cgival, $g_pro, $g_show,$config;
	
	$db_web_rstrt = new db_web_rstrt();
	$db_web_rstrt_tag = new db_web_rstrt_tag();

	$rstrt_list = $db_web_rstrt->admin_get_rstrt_by_ids(array($g_cgival["rstrt_id"]));
	if(empty($rstrt_list[0]))
	{
		throw new Exception("此餐厅不存在");
	}
	$g_show['data']['rstrt_info'] = $rstrt_list[0];
	$g_show['data']['data_list'] = $db_web_rstrt_tag->admin_get_tag_list($g_cgival["rstrt_id"],'',1,0,0);
	$g_show['data']['count'] = count($g_show['data']['data_list']);
	//当前参数输出到页面	
	$g_show['args'] = $g_cgival;
}

$g_show["error"] = 0;
$g_show["errmsg"] = '';
try
{
	admin_check_login();
// 	admin_check_user_priv("foodv2/album_list.php");
	check_cgi_pro();
	get_data();
	$g_show["error"] = 0;
	$g_show["errmsg"] = '';
}
catch(Exception $e)
{
	$g_show["error"] = 1;
	$g_show["errmsg"] = $e->getMessage();
}

show_pro();
exit;


function show_pro()
{
	global $g_cgival, $g_pro, $g_show;
	
	if(isset($_GET['debug']))
		print_r($g_show);
	
	$smarty = p_get_smarty ();
	$smarty->assign ( 'g_show', $g_show );
	if ($g_show["error"] == 1)
	{
		$smarty->display("admin_error.html");
		return;
	}
	$smarty->display ( "foodv2/rstrt/rstrt_tag.html" );
}

?>